package com.ccq.service;

import com.alibaba.fastjson.JSON;
import com.ccq.mapper.BrokerMapper;
import com.ccq.model.Broker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrokerService {
    @Autowired
    BrokerMapper brokerMapper;

    public String borkerlist(){
        List<Broker> ls=brokerMapper.selectalldata();
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }

    public String nices(int id){
        Broker b=brokerMapper.selectByPrimaryKey(id);
        b.setNice(b.getNice()+1);
        int a=brokerMapper.updateByPrimaryKey(b);
        String aListJson = JSON.toJSONString(b);
        System.out.println("添加成功");
        return aListJson;
    }

    public String chengjiaos(){
        List<Broker> ls=brokerMapper.selectChenjiao();
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }

    public String zuling(){
        List<Broker> ls=brokerMapper.selectZuling();
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }

    public String dianzan(){
        List<Broker> ls=brokerMapper.selectDianzan();
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }

    public String quyu(String adress){
        Broker b=new Broker();
        b.setAdress(adress);
        List<Broker> ls=brokerMapper.slectQUYU(b);
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }
}
